<?php
// +----------------------------------------------------------------------
// | author: admin
// +----------------------------------------------------------------------


namespace app\adminapi\controller\setting;


use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\setting\CarTypeLists;
use app\adminapi\logic\setting\CarTypeLogic;
use app\adminapi\validate\setting\CarTypeValidate;


/**
 * CarType控制器
 * Class CarTypeController
 * @package app\adminapi\controller\setting
 */
class CarTypeController extends BaseAdminController
{


    /**
     * @notes 获取列表
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/27 10:41
     */
    public function lists()
    {
        return $this->dataLists(new CarTypeLists());
    }


    /**
     * @notes 添加
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/27 10:41
     */
    public function add()
    {
        $params = (new CarTypeValidate())->post()->goCheck('add');
        $result = CarTypeLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(CarTypeLogic::getError());
    }


    /**
     * @notes 编辑
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/27 10:41
     */
    public function edit()
    {
        $params = (new CarTypeValidate())->post()->goCheck('edit');
        $result = CarTypeLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(CarTypeLogic::getError());
    }


    /**
     * @notes 删除
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/27 10:41
     */
    public function delete()
    {
        $params = (new CarTypeValidate())->post()->goCheck('delete');
        CarTypeLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }


    /**
     * @notes 获取详情
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/27 10:41
     */
    public function detail()
    {
        $params = (new CarTypeValidate())->goCheck('detail');
        $result = CarTypeLogic::detail($params);
        return $this->data($result);
    }

    /**
     * @notes 获取旅行社
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function all()
    {
        $result = CarTypeLogic::getAllData();
        return $this->data($result);
    }


}